class Event(object):
    def __init__(self, name, triggering):
        self.name = name
        self.step = 0
        self.triggering = triggering
        self.parent = None
        self.child = None
        self.content = None
        self.skill = None
        self.triggered_skills = None
        self.player = None
        self.enemy = None
        self.card = None
        self.cards = None
        self.num = None
        self.index = None
        self.result = None
        self.child_result = None
        self.prompt = None
        self.trigger_event = None
        self.pos = None
        self.fields = None

    def finish(self):
        if self.triggering == 2:
            self.triggering += 1
        elif self.triggering == 0:
            self.triggering = 4
        else:
            raise RuntimeError(f"结束事件错误（{event.name})")

    def cancel(self):
        self.result = "canceled"
        self.triggering = 4

    def set_content(self, content):
        self.content = content()
        return self

    def create_event(self, name="", triggering=1):
        self.child = Event(name, triggering)
        self.child.parent = self
        return self.child

    def goto(self, step):
        self.step = step - 1

    def redo(self):
        self.step -= 1

    def forward(self):
        self.step += 1


event = Event("end of world", triggering=0)
